<template>
  <div>
    <!-- 顶部操作区域 -->
    <div
      style="
        margin-top: 15px;
        width: 300px;
        margin-left: 45px;
        margin-bottom: 15px;
      "
    >
      <el-input
        placeholder="请输入订单号"
        v-model="query"
        class="input-with-select"
        :clearable="true"
        @blur="reList()"
      >
        <el-button
          slot="append"
          icon="el-icon-search"
          @click="getAllMedicalRecordByOrderNumber()"
        ></el-button>
      </el-input>
    </div>
    <!-- 表格部分 -->
    <el-table
      :data="
        tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
      "
      border
      style="width: 100%"
    >
      <el-table-column
        fixed
        prop="medical_pkid"
        label="记录编号"
        width="100%"
        align="center"
      >
      </el-table-column>
      <el-table-column fixed prop="order_number" label="订单号" align="center">
      </el-table-column>
      <el-table-column
        fixed
        prop="diagnosis_result"
        label="诊断结果"
        width="100%"
        align="center"
      >
      </el-table-column>
      <el-table-column
        fixed
        prop="is_medication_required"
        label="是否用药"
        align="center"
      >
      </el-table-column>

      <el-table-column
        fixed
        prop="medication_details"
        label="用药详情"
        align="center"
      >
      </el-table-column>
      <el-table-column
        fixed
        prop="doctor_advice"
        label="医生建议"
        align="center"
      >
      </el-table-column>
    </el-table>
    <!-- 分页器 -->
    <el-pagination
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
      :current-page="currentPage"
      :page-sizes="[5, 10]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.length"
    ></el-pagination>
  </div>
</template>

<script>
import {
  getAllMedicalRecord,
  getAllMedicalRecordByOrderNumber,
} from "@/utils/request";
export default {
  name: "DyymanagevueMedicalRecordsPage",

  data() {
    return {
      query: "",
      drawer: false,
      tableData: [],
      currentPage: 1, // 当前页码
      pageSize: 5, // 每页显示条数
      totalItems: 0, // 总记录数
      handle_obj: "", //操作对象
    };
  },

  mounted() {
    this.getList();
  },

  methods: {
    async getList() {
      await getAllMedicalRecord()
        .then((res) => {
          this.tableData = res.data.data;
        })
        .catch((error) => {
          // 处理错误
          console.error(error);
        });
    },
    reList() {
      this.getList();
    },
    getAllMedicalRecordByOrderNumber() {
      if (this.query != "") {
        getAllMedicalRecordByOrderNumber(this.query)
          .then((res) => {
            this.tableData = res.data.data;
          })
          .catch((err) => {});
      }
    },
    // 分页器页码变化事件处理函数
    handleCurrentChange(newPage) {
      this.currentPage = newPage; // 更新当前页码
    },
    handleSizeChange(newSize) {
      this.pageSize = newSize; //更新每页数据条数
    },
  },
};
</script>

<style lang="scss" scoped>
.el-pagination {
  position: absolute;
  bottom: 0;
  left: 45%;
  /* width: 30%; */
  bottom: 5%;
  background-color: #fff;
  z-index: 999; /* 可以根据需要设置z-index值，确保分页器显示在其他内容上方 */
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1); /* 添加阴影效果（可选） */
}
</style>